using System.Collections.Generic;

namespace OffsetPath
{
    public class ClassO_List_LineArco : List<ClasseBaseLineaArcoClassAf>
    {
        public bool MethodA()
        {
            List<ClassO_List_LineArco.SubClassA> list = new List<ClassO_List_LineArco.SubClassA>();
            for (int i = 0; i < base.Count; i++)
            {
                ClassO_List_LineArco.SubClassA item = new ClassO_List_LineArco.SubClassA {
                                       b = base[i]
                                   };
                item.b.f(item.c);
                list.Add(item);
            }
            ClassO_List_LineArco.SubClassB comparer = new ClassO_List_LineArco.SubClassB();
            list.Sort(comparer);
            int num2 = 0;
            List<PuntoDueD> list2 = new List<PuntoDueD>();
            bool flag = false;
            while ((num2 < list.Count) && !flag)
            {
                int num3 = num2 + 1;
                double num4 = list[num2].c.o();
                while ((!flag && (num3 < list.Count)) && (list[num3].c.e() < num4))
                {
                    if (list[num2].c.e(list[num3].c) && list[num2].b.MethodB(list[num3].b, list2))
                    {
                        flag = true;
                    }
                    num3++;
                }
                num2++;
            }
            return flag;
        }

        public void MethodA(ClasseBaseLineaArcoClassAf A_0)
        {
            if (A_0 is ForseLineaClassA)
            {
                base.Add(new ForseLineaClassA(A_0 as ForseLineaClassA));
            }
            else if (A_0 is ForseArco2ClassQ)
            {
                base.Add(new ForseArco2ClassQ(A_0 as ForseArco2ClassQ));
            }
        }

        public void MethodA(List<ClasseBaseLineaArcoClassAf> A_0)
        {
            base.Clear();
            for (int i = 0; i < A_0.Count; i++)
            {
                base.Add(A_0[i].MethodA());
            }
        }

        public bool MethodA(ClassO_List_LineArco A_0)
        {
            int count = base.Count;
            if (count >= 1)
            {
                int num2 = A_0.Count;
                if (num2 < 1)
                {
                    return false;
                }
                if (base[0].h().MethodB(A_0[0].h()))
                {
                    this.b();
                    this.AggiungiElementiLineaArco(A_0);
                    return true;
                }
                if (base[0].h().MethodB(A_0[num2 - 1].i()))
                {
                    this.b();
                    A_0.b();
                    this.AggiungiElementiLineaArco(A_0);
                    return true;
                }
                if (base[count - 1].i().MethodB(A_0[0].h()))
                {
                    this.AggiungiElementiLineaArco(A_0);
                    return true;
                }
                if (base[count - 1].i().MethodB(A_0[num2 - 1].i()))
                {
                    A_0.b();
                    this.AggiungiElementiLineaArco(A_0);
                    return true;
                }
            }
            return false;
        }

        public bool MethodA(bool A_0)
        {
            int count = base.Count;
            if (A_0)
            {
                return base[0].h().MethodB(base[count - 1].i());
            }
            for (int i = 0; i < count; i++)
            {
                int num3 = (i + 1) % count;
                if (!base[i].i().MethodB(base[num3].h()))
                {
                    return false;
                }
            }
            return true;
        }

        public void MethodA(double A_0)
        {
            for (int i = 0; i < base.Count; i++)
            {
                if (base[i].g() < A_0)
                {
                    base.RemoveAt(i);
                }
            }
        }

        public ClasseBaseLineaArcoClassAf MethodA(int A_0)
        {
            ClasseBaseLineaArcoClassAf classAf = base[A_0];
            base.RemoveAt(A_0);
            return classAf;
        }

        public void MethodA(List<PuntoDueD> A_0, List<int> A_1, List<int> A_2)
        {
            List<ClassO_List_LineArco.SubClassA> list = new List<ClassO_List_LineArco.SubClassA>();
            for (int i = 0; i < base.Count; i++)
            {
                ClassO_List_LineArco.SubClassA item = new ClassO_List_LineArco.SubClassA {
                                       b = base[i]
                                   };
                item.b.f(item.c);
                item.d = i;
                list.Add(item);
            }
            ClassO_List_LineArco.SubClassB comparer = new ClassO_List_LineArco.SubClassB();
            list.Sort(comparer);
            int num2 = 0;
            List<PuntoDueD> list2 = new List<PuntoDueD>();
            while (num2 < list.Count)
            {
                int num3 = num2 + 1;
                double num4 = list[num2].c.o();
                while ((num3 < list.Count) && (list[num3].c.e() < num4))
                {
                    if (list[num2].c.e(list[num3].c) && list[num2].b.MethodB(list[num3].b, list2))
                    {
                        while (list2.Count > 0)
                        {
                            A_0.Add(list2[list2.Count - 1]);
                            list2.RemoveAt(list2.Count - 1);
                            A_1.Add(list[num2].d);
                            A_2.Add(list[num3].d);
                        }
                    }
                    num3++;
                }
                num2++;
            }
        }

        public void MethodA(List<ClasseBaseLineaArcoClassAf> A_0, List<PuntoDueD> A_1, List<int> A_2, List<int> A_3, ClassAb A_4, ClassAb A_5)
        {
            List<ClassO_List_LineArco.SubClassA> list = new List<ClassO_List_LineArco.SubClassA>();
            for (int i = 0; i < base.Count; i++)
            {
                ClassO_List_LineArco.SubClassA item = new ClassO_List_LineArco.SubClassA {
                                       b = base[i]
                                   };
                item.b.f(item.c);
                item.d = i;
                item.subA = true;
                if (A_5.e(item.c))
                {
                    list.Add(item);
                }
            }
            for (int j = 0; j < A_0.Count; j++)
            {
                ClassO_List_LineArco.SubClassA a2 = new ClassO_List_LineArco.SubClassA {
                                     b = A_0[j]
                                 };
                a2.b.f(a2.c);
                a2.d = j;
                a2.subA = false;
                if (A_4.e(a2.c))
                {
                    list.Add(a2);
                }
            }
            ClassO_List_LineArco.SubClassB comparer = new ClassO_List_LineArco.SubClassB();
            list.Sort(comparer);
            int num3 = 0;
            List<PuntoDueD> list2 = new List<PuntoDueD>();
            while (num3 < list.Count)
            {
                int num4 = num3 + 1;
                double num5 = list[num3].c.o();
                while ((num4 < list.Count) && (list[num4].c.e() < num5))
                {
                    if (((list[num3].subA ^ list[num4].subA) && list[num3].c.e(list[num4].c)) && list[num3].b.MethodB(list[num4].b, list2))
                    {
                        while (list2.Count > 0)
                        {
                            A_1.Add(list2[list2.Count - 1]);
                            list2.RemoveAt(list2.Count - 1);
                            if (list[num3].subA)
                            {
                                A_2.Add(list[num3].d);
                            }
                            else
                            {
                                A_2.Add(list[num4].d);
                            }
                            if (list[num3].subA)
                            {
                                A_3.Add(list[num4].d);
                            }
                            else
                            {
                                A_3.Add(list[num3].d);
                            }
                        }
                    }
                    num4++;
                }
                num3++;
            }
        }

        public void b()
        {
            base.Reverse();
            for (int i = 0; i < base.Count; i++)
            {
                base[i].m();
            }
        }

        public void b(List<ClasseBaseLineaArcoClassAf> A_0)
        {
            base.Clear();
            for (int i = 0; i < A_0.Count; i++)
            {
                base.Add(A_0[i]);
            }
        }

        public void AggiungiElementiLineaArco(List<ClasseBaseLineaArcoClassAf> A_0)
        {
            for (int i = 0; i < A_0.Count; i++)
            {
                base.Add(A_0[i]);
            }
            A_0.Clear();
        }

        ~ClassO_List_LineArco()
        {
        }

        public class SubClassA
        {
            public bool subA = true;
            public ClasseBaseLineaArcoClassAf b;
            public ClassAb c = new ClassAb();
            public int d;
        }

        public class SubClassB : IComparer<ClassO_List_LineArco.SubClassA>
        {
            public int Compare(ClassO_List_LineArco.SubClassA L1, ClassO_List_LineArco.SubClassA L2)
            {
                if (L1 == L2)
                {
                    return 0;
                }
                if (L1.c.GetEndPnt().X > L2.c.GetEndPnt().X)
                {
                    return 1;
                }
                if (L1.c.GetEndPnt().X == L2.c.GetEndPnt().X)
                {
                    return 0;
                }
                return -1;
            }
        }
    }
}

